package pchi.pchicamera.fragmenttabs;

import java.util.ArrayList;

import pchi.pchicamera.R;
import pchi.pchicamera.adapters.EditorAdapter;
import pchi.pchicamera.data.MyItemGirdviewHolder;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class TabEdittor extends Fragment implements OnItemClickListener {

	GridView gridView;

	ArrayList<MyItemGirdviewHolder> effect = new ArrayList<MyItemGirdviewHolder>();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View root = inflater.inflate(R.layout.tab_edittor, container, false);

		effect.add(new MyItemGirdviewHolder("Black and Whilte",
				R.drawable.black_whilte_1));
		effect.add(new MyItemGirdviewHolder("Black and Whilte",
				R.drawable.black_whilte_2));
		effect.add(new MyItemGirdviewHolder("Black and Whilte",
				R.drawable.black_whilte_3));
		effect.add(new MyItemGirdviewHolder("Black and Whilte",
				R.drawable.black_whilte_4));

		effect.add(new MyItemGirdviewHolder("Color Contrast",
				R.drawable.color_contrast_1));
		effect.add(new MyItemGirdviewHolder("Color Contrast",
				R.drawable.color_contrast_2));
		effect.add(new MyItemGirdviewHolder("Color Contrast",
				R.drawable.color_contrast_3));

		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_1));
		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_2));
		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_3));
		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_4));
		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_5));
		effect.add(new MyItemGirdviewHolder("Brightness",
				R.drawable.brightness_6));

		effect.add(new MyItemGirdviewHolder("Color Boost",
				R.drawable.color_boost_1));
		effect.add(new MyItemGirdviewHolder("Color Boost",
				R.drawable.color_boost_2));
		effect.add(new MyItemGirdviewHolder("Color Boost",
				R.drawable.color_boost_3));

		effect.add(new MyItemGirdviewHolder("dark", R.drawable.dark));

		effect.add(new MyItemGirdviewHolder("Emboss", R.drawable.emboss));

		effect.add(new MyItemGirdviewHolder("Engraving", R.drawable.engraving));

		effect.add(new MyItemGirdviewHolder("Flea", R.drawable.flea));

		effect.add(new MyItemGirdviewHolder("Gamma", R.drawable.gamma_1));
		effect.add(new MyItemGirdviewHolder("Gamma", R.drawable.gamma_2));
		effect.add(new MyItemGirdviewHolder("Gamma", R.drawable.gamma_3));
		effect.add(new MyItemGirdviewHolder("Gamma", R.drawable.gamma_4));

		effect.add(new MyItemGirdviewHolder("Hue", R.drawable.hue_1));
		effect.add(new MyItemGirdviewHolder("Hue", R.drawable.hue_2));
		effect.add(new MyItemGirdviewHolder("Hue", R.drawable.hue_3));

		effect.add(new MyItemGirdviewHolder("Reducing Color Deth",
				R.drawable.reducing_color_depth_1));
		effect.add(new MyItemGirdviewHolder("Reducing Color Deth",
				R.drawable.reducing_color_depth_2));
		effect.add(new MyItemGirdviewHolder("Reducing Color Deth",
				R.drawable.reducing_color_depth_3));
		effect.add(new MyItemGirdviewHolder("Reducing Color Deth",
				R.drawable.reducing_color_depth_4));

		effect.add(new MyItemGirdviewHolder("Saturation",
				R.drawable.saturation_1));
		effect.add(new MyItemGirdviewHolder("Saturation",
				R.drawable.saturation_2));
		effect.add(new MyItemGirdviewHolder("Saturation",
				R.drawable.saturation_3));
		effect.add(new MyItemGirdviewHolder("Saturation",
				R.drawable.saturation_4));

		effect.add(new MyItemGirdviewHolder("Sepia Toning",
				R.drawable.sepia_toning_1));
		effect.add(new MyItemGirdviewHolder("Sepia Toning",
				R.drawable.sepia_toning_2));
		effect.add(new MyItemGirdviewHolder("Sepia Toning",
				R.drawable.sepia_toning_3));
		effect.add(new MyItemGirdviewHolder("Sepia Toning",
				R.drawable.sepia_toning_4));

		effect.add(new MyItemGirdviewHolder("Shading", R.drawable.shading_1));
		effect.add(new MyItemGirdviewHolder("Shading", R.drawable.shading_2));
		effect.add(new MyItemGirdviewHolder("Shading", R.drawable.shading_3));
		effect.add(new MyItemGirdviewHolder("Shading", R.drawable.shading_4));

		effect.add(new MyItemGirdviewHolder("Smooth", R.drawable.smooth));

		effect.add(new MyItemGirdviewHolder("Snow falling",
				R.drawable.snow_falling));

		effect.add(new MyItemGirdviewHolder("Tint", R.drawable.tint_1));
		effect.add(new MyItemGirdviewHolder("Tint", R.drawable.tint_2));
		effect.add(new MyItemGirdviewHolder("Tint", R.drawable.tint_3));

		gridView = (GridView) root.findViewById(R.id.gridView1);

		gridView.setAdapter(new EditorAdapter(getActivity(), effect));

		gridView.setOnItemClickListener(this);

		return root;
	}

	OnTabImagesPreviewSelectedListener mCallbackTabImagesPreview;

	public interface OnTabImagesPreviewSelectedListener {
		public void OnTabImagesPreviewSelected(int position);
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			mCallbackTabImagesPreview = (OnTabImagesPreviewSelectedListener) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ " must implement OnHeadlineSelectedListener");
		}
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		mCallbackTabImagesPreview.OnTabImagesPreviewSelected(position);
	}

}
